<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>13 计算属性的setter</title>
</head>
<body>
  <div id="app">
    <input type="text" v-model="firstName"> + 
    <input type="text" v-model="lastName">  = 
    <input type="text" v-model="fullName">

  </div>
</body>
<script src="lib/vue.js"></script>
<script>
  const app = new Vue({
    data: {
      firstName: '',
      lastName: '',
    },
    computed: {
      fullName: {
        get () {
          return this.firstName + this.lastName
        },
        set (val) {
          const items = val.split(' ')
          this.firstName = items[0]
          this.lastName = items[1]
        }
      }
    }
  }).$mount('#app')

  app.fullName = '吴 大勋'
</script>
</html>